package com.xbts.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xbts.system.domain.SeiTask;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 下达任务Mapper接口
 *
 * @author xbts
 * @date 2023-08-22
 */
public interface SeiTaskMapper extends BaseMapper<SeiTask> {

    @Select("SELECT t.*, u.nick_name as head_of_tender_name, " +
            "d1.dict_name as head_of_tech_name, " +
            "d2.dict_name as major_name, " +
            "d3.dict_name as tender_platform_name, " +
            "d4.dict_name as tenderer_name, " +
            "ty.name as type_name " +

            "FROM sei_task t " +
            "LEFT JOIN sys_user u on u.user_id = t.head_of_tender " +
            "LEFT JOIN sei_data_dict d1 on d1.data_dict_id = t.head_of_tech " +
            "LEFT JOIN sei_data_dict d2 on d2.data_dict_id = t.major " +
            "LEFT JOIN sei_data_dict d3 on d3.data_dict_id = t.tender_platform " +
            "LEFT JOIN sei_data_dict d4 on d4.data_dict_id = t.tenderer " +
            "LEFT JOIN sei_task_type ty on ty.id = t.type_id " +
            " WHERE t.tender_id = #{tenderId}")
    SeiTask selectTaskInfo(String tenderId);


    @Select("SELECT t.*, u.nick_name as head_of_tender_name, " +
            "d1.dict_name as head_of_tech_name, " +
            "d2.dict_name as major_name, " +
            "d3.dict_name as tender_platform_name, " +
            "d4.dict_name as tenderer_name, " +
            "ty.name as type_name " +

            "FROM sei_task t " +
            "LEFT JOIN sys_user u on u.user_id = t.head_of_tender " +
            "LEFT JOIN sei_data_dict d1 on d1.data_dict_id = t.head_of_tech " +
            "LEFT JOIN sei_data_dict d2 on d2.data_dict_id = t.major " +
            "LEFT JOIN sei_data_dict d3 on d3.data_dict_id = t.tender_platform " +
            "LEFT JOIN sei_data_dict d4 on d4.data_dict_id = t.tenderer " +
            "LEFT JOIN sei_task_type ty on ty.id = t.type_id " +
            " ${ew.customSqlSegment}")
    List<SeiTask> selectTaskList(@Param(Constants.WRAPPER) QueryWrapper<SeiTask> queryWrapper);
}
